#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stack>
#include <queue>
using namespace std;

void Test_Stack()
{
	stack<int> st;
	st.push(1);
	st.push(2);
	st.push(3);
	st.push(4);
	st.push(5);
	while (!st.empty())
	{
		cout << st.top() << " ";
		st.pop();
	}
	cout << endl;
}

void Test_Queue()
{
	queue<int> q;
	q.push(1);
	q.push(2);
	q.push(3);
	q.push(4);
	q.push(5);
	while (!q.empty())
	{
		cout << q.front() << " ";
		q.pop();
	}
	cout << endl;
}

class Solution1 {
public:
	bool IsPopOrder(vector<int> pushV, vector<int> popV) {
		vector<int>::iterator it1 = pushV.begin();
		vector<int>::iterator it2 = popV.begin();
		stack<int> st;
		while (it1 != pushV.end())
		{
			st.push(*it1);
			while (!st.empty() && st.top() == *it2)
			{
				st.pop();
				++it2;
			}
			++it1;
		}
		if (it2 != popV.end())
		{
			return false;
		}
		else
		{
			return true;
		}
	}
};

class Solution2 {
public:
	bool IsPopOrder(vector<int> pushV, vector<int> popV) {
		int i = 0, j = 0;
		stack<int> st;
		for (int i = 0; i < pushV.size(); i++)
		{
			st.push(pushV[i]);
			while (!st.empty() && st.top() == popV[j])
			{
				j++;
				st.pop();
			}
		}
		return st.empty();
	}
};

void Test()
{
	vector<int> vi;
	vi.push_back(1);
	vi.push_back(2);
	vi.push_back(3);
	vi.push_back(4);
	vi.push_back(5);

	auto it = vi.begin();
	vi.erase(it);
	/*vi.erase(it);
	vi.erase(it);
	vi.erase(it);*/

}

int main()
{
	Test_Stack();
	Test_Queue();
	//Test();
	return 0;
}